//
//  OMTextField.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/4/21.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMTextField.h"
#import "MainConfigure.h"
@interface OMTextField () <UITextFieldDelegate>
@end
@implementation OMTextField

- (instancetype)init
{
    self = [super init];
    [self configure];
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    [self configure];
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    [self configure];
    return self;
}

- (void)configure
{
    self.delegate = self;
}


- (CGRect)leftViewRectForBounds:(CGRect)bounds
{
    CGRect iconRect = [super leftViewRectForBounds:bounds];
    iconRect.origin.x += SM_SIZE(30);
    return iconRect;
}

- (CGRect)textRectForBounds:(CGRect)bounds
{
    return CGRectInset(bounds, SM_SIZE(90), 0);
}

- (CGRect)editingRectForBounds:(CGRect)bounds
{
    return CGRectInset(bounds, SM_SIZE(90), 0);
}


-(BOOL)canPerformAction:(SEL)action withSender:(id)sender {

    UIMenuController*menuController = [UIMenuController sharedMenuController];

    if(menuController) {

        [UIMenuController sharedMenuController].menuVisible=NO;
        
    }
    return !self.selectdisable;
    
}


#pragma mark - UITextFieldDelegate 
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (self.om_delegate && [self.om_delegate respondsToSelector:@selector(textFieldShouldReturn:)]) {
        return [self.om_delegate textFieldShouldReturn:self];
    }
    return YES;
}
@end
